/**
 *
 */
package siebes.rmi.sorter;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

/**
 * @author eddie
 *Voert een bubblesort uit
 */
public class BubbleSort extends UnicastRemoteObject implements ISorter {

    /**
     *Integriteit checker.
     */
    private static final long serialVersionUID = 7492968842631855409L;


    /**
     *@throws RemoteException todo
     */
    public BubbleSort() throws RemoteException {

    }

    /* (non-Javadoc)
     * @see siebes.rmi.sorter.ISorter#sort(java.lang.Comparable[])
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Override
    public final Comparable[] sort(final Comparable[] t) {

        Comparable temp;
        Comparable[] comparable = t;
        for (int i = 0; i < comparable.length; i++) {
            for (int j = 1; j < (comparable.length - i); j++) {
                if (comparable[j - 1].compareTo(comparable[j]) > 0) {
                    temp = comparable[j - 1];
                    comparable[j - 1] = comparable[j];
                    comparable[j] = temp;
                }
            }
        }
        return comparable;
    }
}
